﻿namespace DeviceCommons.DeviceMessages.Models.V1
{
    public class DeviceMessageInfoReading : IDeviceMessageInfoReading
    {
        public DeviceMessageInfoReading()
        {
        }

        public byte[] Offset
        {
            get
            {
                byte[] bytes = new byte[2];
                bytes[0] = (byte)(TimeOffset >> 8);
                bytes[1] = (byte)TimeOffset;
                return bytes;
            }
            set => TimeOffset = (short)(value[0] << 8 | value[1]);
        }

        public short TimeOffset { get; set; } = 0;

        public IDeviceMessageInfoReadingStates? State { get; set; }

        public int DataLength => 2 + (State?.DataLength ?? 0);
    }
}
